<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var countAsterisks = function (s) {
      let is = true
      let count = 0
      for (let cur of s) {
        if (is && cur == '*') count += 1;
        if (cur == '|') is = !is;
      }
      return count
    }
    console.log(countAsterisks(s = "l|*e*et|c**o|*de|"))
  </script>
</body>

</html>